package com.ss.ttvideoengine.c;

import com.ss.ttvideoengine.d.TTVideoError;

import org.json.JSONArray;
import org.json.JSONObject;

public final class d extends a {
    private static String f = "203.107.1.4";
    private static String g = "131950";

    public d(String arg1, HttpRequest arg2) {
        super(arg1, arg2);
    }

    static void a(d arg4, JSONObject jsonObject, TTVideoError ttVideoError) {
        String v0 = null;
        if (ttVideoError != null) {
            ttVideoError.domain = "kTTVideoErrorDomainHTTPDNS";
            arg4.onError(ttVideoError);
            return;
        }

        JSONArray ipsJA = jsonObject.optJSONArray("ips");
        if (ipsJA != null && ipsJA.length() != 0) {
            try {
                v0 = ipsJA.getString(0);
            } catch (Exception v1_1) {
            }

            if (v0 == null) {
                ttVideoError = new TTVideoError("kTTVideoErrorDomainHTTPDNS", -9997);
                arg4.onError(ttVideoError);
                return;
            } else {
                arg4.a(v0);
                return;
            }
        }
        ttVideoError = new TTVideoError("kTTVideoErrorDomainHTTPDNS", -9997);
        arg4.onError(ttVideoError);
    }

    public final void b() {
        this.mHttpRequest.request("https://" + f + "/" + g + "/d?host=" + this.c, new HttpRequest.Callback() {
            @Override
            public final void callback(JSONObject respJo, TTVideoError error) {
                com.ss.ttvideoengine.c.d.a(com.ss.ttvideoengine.c.d.this, respJo, error);
            }
        });
    }

    public final void interrupt() {
        if (!this.isThreadInterrupted) {
            this.isThreadInterrupted = true;
            this.mHttpRequest.cancel();
        }
    }
}

